package main

import (
	"embed"
	"os"
	"os/exec"

	"github.com/wailsapp/wails/v2"
	"github.com/wailsapp/wails/v2/pkg/options"
	"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)

//go:embed all:frontend/dist
var assets embed.FS

func main() {

	os.Setenv("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--disable-web-security")

	// Create an instance of the app structure
	app := NewApp()

	path, look_path_err := exec.LookPath("./chatlog/ffmpeg")
	if look_path_err == nil {
		cmd := exec.Command(path, "-version")

		println("cmd.Run():", cmd.Run())
	}
	println("look_path_err:", look_path_err)
	println("path:", path)

	// Create application with options
	err := wails.Run(&options.App{
		Title:     "消息助手",
		Width:     1024,
		Height:    768,
		MinWidth:  600,
		MinHeight: 500,
		AssetServer: &assetserver.Options{
			Assets: assets,
		},
		Frameless: true,
		OnStartup: app.startup,
		Bind: []any{
			app,
		},
	})
	app.StopChatlog()
	if err != nil {
		println("Error:", err.Error())
	}
}
